package com.ipDev.moyvSys.utils;

import lombok.Data;

@Data
public class Result<T> {
    private T data;
    private Integer code;
    private String msg;
    public Result( Integer code,T data) {
        this.data = data;
        this.code = code;
    }

    public Result(Integer code, String msg, T data) {
        this.data = data;
        this.code = code;
        this.msg = msg;
    }
    public Result(String msg) {
        this.msg = msg;
    }
    public static <T> Result<T> success(T data) {
        return new Result<>(0,"操作成功",data);
    }
    public static <T> Result<T> success() {
        return new Result<>(0,"操作成功", null);
    }
    public static <T> Result<T> success(Integer code, String msg, T data) {
        return new Result<>(code,msg,data);
    }
    public static <T> Result<T> success(String msg) {
        return new Result<>(0,msg, null);
    }
    public static <T> Result<T> error(String msg) {
        return new Result<>(1,msg,null);
    }
    public static <T> Result<T> error(Integer code,String msg) {
        return new Result<>(code,msg,null);
    }
    
}
